package us.mooresr.webtroopmanager.client.ui;

import us.mooresr.webtroopmanager.client.place.DashboardPlace;
import us.mooresr.webtroopmanager.client.place.ImportPlace;
import us.mooresr.webtroopmanager.client.place.RoleListPlace;
import us.mooresr.webtroopmanager.client.place.UserListPlace;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class AdminViewImpl extends Composite implements AdminView {
	private AdminView.Presenter presenter;
	
	private static AdminViewUiBinder uiBinder = GWT.create(AdminViewUiBinder.class);
	
	interface AdminViewUiBinder extends UiBinder<Widget, AdminViewImpl> {
		
	}
	
	@UiField
	Button initializeButton;
	
	@UiField
	Button preloadButton;
	
	@UiField 
	Button manageUsersButton;
	
	@UiField
	Button manageRolesButton;
	
	@UiField
	Button backButton;
	
	@UiHandler("manageRolesButton")
	void onManageRolesClick(ClickEvent e) {
		presenter.goTo(new RoleListPlace());
	}
	
	@UiHandler("backButton")
	void onBackClick(ClickEvent e) {
		presenter.goTo(new DashboardPlace());
	}
	
	@UiHandler("initializeButton")
	void onIntializeButton(ClickEvent e) {
		presenter.doInitializeUsers();
	}
	
	@UiHandler("manageUsersButton")
	void onManageUsers(ClickEvent e) {
		presenter.goTo(new UserListPlace());
	}
	
	@UiHandler("preloadButton")
	void onPreloadData(ClickEvent e) {
		presenter.goTo(new ImportPlace());
		
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
		
	}
	
	public AdminViewImpl() {
		
		initWidget(uiBinder.createAndBindUi(this));
		
	}
	
}
